Make texture variants of some pixbuf utils
authorMatthias Clasen <mclasen@redhat.com>
Thu, 30 Nov 2017 12:54:27 +0000 (07:54 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 30 Nov 2017 12:54:27 +0000 (07:54 -0500)
This will let us avoid direct pixbuf use in some places.

gtk/gdkpixbufutils.c
gtk/gdkpixbufutilsprivate.h

index ae57455d7fb2a46342bc94886361b986a4f2f07b..b47ebf9df89216fa7301c731af62207ca51cd32a 100644 (file)
@@ -355,3 +355,37 @@ gtk_make_symbolic_pixbuf_from_file (GFile   *file,
 
   return pixbuf;
 }
+
+GdkTexture *
+gtk_make_symbolic_texture_from_resource (const char  *path,
+                                         int          width,
+                                         int          height,
+                                         double       scale,
+                                         GError     **error)
+{
+  GdkPixbuf *pixbuf;
+  GdkTexture *texture;
+
+  pixbuf = gtk_make_symbolic_pixbuf_from_resource (path, width, height, scale, error);
+  texture = gdk_texture_new_for_pixbuf (pixbuf);
+  g_object_unref (pixbuf);
+
+  return texture;
+}
+
+GdkTexture *
+gtk_make_symbolic_texture_from_file (GFile   *file,
+                                     int      width,
+                                     int      height,
+                                     double   scale,
+                                     GError **error)
+{
+  GdkPixbuf *pixbuf;
+  GdkTexture *texture;
+
+  pixbuf = gtk_make_symbolic_pixbuf_from_file (file, width, height, scale, error);
+  texture = gdk_texture_new_for_pixbuf (pixbuf);
+  g_object_unref (pixbuf);
+
+  return texture;
+}
index 8e398e1be020424328d795c2caf8e71ea60afc12..a11ce9bc96df84ac685efb485710ea674b740b9a 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef __GDK_PIXBUF_UTILS_PRIVATE_H__
 #define __GDK_PIXBUF_UTILS_PRIVATE_H__
 
-#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk/gdk.h>
 
 G_BEGIN_DECLS
 
@@ -46,6 +46,16 @@ GdkPixbuf *gtk_make_symbolic_pixbuf_from_resource (const char    *path,
                                                    int            height,
                                                    double         scale,
                                                    GError       **error);
+GdkTexture *gtk_make_symbolic_texture_from_file     (GFile         *file,
+                                                     int            width,
+                                                     int            height,
+                                                     double         scale,
+                                                     GError       **error);
+GdkTexture *gtk_make_symbolic_texture_from_resource (const char    *path,
+                                                     int            width,
+                                                     int            height,
+                                                     double         scale,
+                                                   GError       **error);
 G_END_DECLS
 
 #endif  /* __GDK_PIXBUF_UTILS_PRIVATE_H__ */